package cn.tedu.file;

import java.io.*;

/*字节输入流*/
public class TestIn {
    public static void main(String[] args) {
        //method1();//测试普通字节输入流

        method2();//测试高效字节输入流
    }

    private static void method2() {
        InputStream in=null;
        try {
            in=new BufferedInputStream(new FileInputStream(new File("D:\\ready\\1.txt")));
            InputStream in2=new BufferedInputStream(new FileInputStream("D:\\ready\\1.txt"));

            int b;
            while ((b=in.read())!=-1){
                System.out.println(b);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


    }

    private static void method1() {
        InputStream in=null;
        try {
            //InputStream in=new FileInputStream(new File("D:\\ready\\1.txt"));
            in=new FileInputStream("D:\\ready\\1.txt");
            int b;
            while ((b=in.read())!=-1){
                System.out.println(b);
            }


        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

}
